package com.sptpc.demo.controller;

import com.sptpc.demo.controller.requests.AddOrderRequest;
import com.sptpc.demo.model.Order;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {

    @GetMapping("/")
    public Order addNewOrder(@RequestBody AddOrderRequest request){
    log.info("订单信息：{}",request);
    Order order=new Order();
        BeanUtils.copyProperties(request,order);
        orderService.addNewOrder(order,request,getItems());
    return order;
}
//get /order/张三
    public List<Order> searchOrderByCustomer(@PathVariable String customer){
      return orderService.findOrdersByCustomer(customer);
    }


}


